#ifndef __COMMON_H
#define __COMMON_H

#define vi *(volatile unsigned int *)

#define set_zero(addr, bit)	((vi addr) &= (~(0x01<<(bit))))
#define set_one(addr, bit)	((vi addr) |= (0x01<<(bit)))

#define set_bit(addr, bit, val)		((vi addr) = ((vi addr)&=(~(0x01<<(bit)))) | ((val)<<(bit)))

#define set_2bit(addr, bit, val)	((vi addr) = ((vi addr)&(~(0x03<<(bit)))) | ((val)<<(bit)))

#define set_nbit(addr, bit, len, val)	\
	((vi addr) = (((vi addr)&(~(((0x01<<(len))-1)<<(bit)))) | ((val)<<(bit))))

#define get_bit(addr, bit)	(((vi addr)&(0x01<<(bit))) > 0)

#define get_val(addr, val)	((val) = vi addr)
#define read_val(addr)	(vi (addr))
#define set_val(addr, val)	((vi addr) = (val))
#define or_val(addr, val)	((vi addr) |= (val))


typedef unsigned char 	u8;
typedef unsigned short 	u16;
typedef unsigned int 	u32;


int delay(int);

#endif
